package ConnDB;
import java.sql.*;
public class ConnDb2
{
    String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
    String sConnStr = "jdbc:odbc:student";
    Connection conn = null;
    ResultSet rs = null;
	 Statement stmt =null;
	 
    public ConnDb2()  
    {
     try 
     {
         Class.forName(sDBDriver);
			setConnection();
			stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, 
               ResultSet.CONCUR_UPDATABLE);
     }
     catch(java.lang.ClassNotFoundException e) 
     {
      System.err.println("ConnDatabase(): " + e.getMessage());
     }
     catch(SQLException ex)
     {
      System.err.println("ConnDatabase(): " + ex.getMessage());
     }
    }
    public int executeUpdate(String sql) throws SQLException
    {
     
       int num=stmt.executeUpdate(sql);
		 return num;
    }

    public ResultSet executeQuery(String sql) throws SQLException
    {
       rs = null;
       rs = stmt.executeQuery(sql);
       return rs;
    }
    public void setConnection() throws SQLException
    {
     conn = DriverManager.getConnection(sConnStr);
    }
    public void closeConnection() throws SQLException
    {
      if(conn==null) return;
      conn.close();
      conn=null;
      stmt=null;
    }
}





